package com.example.provider.com.sjf.biz;


import com.example.provider.com.sjf.dao.ProviderMapper;
import com.example.provider.com.sjf.pojo.Providers;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class ProviderBizImpl implements ProviderBiz {
    @Autowired
    private ProviderMapper providerMapper;

    @Override
    public PageInfo<Providers> getAll(int pageno) {
        PageHelper.startPage(pageno, 5);
        List<Providers> all = this.providerMapper.getAll();
        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
        for (int i = 0; i < all.size(); i++) {
            Date date = all.get(i).getCreationDate();
            String s = sd.format(date);
            all.get(i).setCreationDates(s);
        }
        PageInfo<Providers> pageInfo = new PageInfo(all);
        return pageInfo;
    }

    @Override
    public Providers show(Long id) {
        return this.providerMapper.show(id);
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return this.providerMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Providers record) {
        return this.providerMapper.insert(record);
    }

    @Override
    public Providers selByid(Long id) {
        return this.providerMapper.selByid(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Providers record) {
        return this.providerMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<Providers> selM(Providers record) {
        return this.providerMapper.selM(record);
    }
}
